{extend name="index@common/base"/} 
{block name="style"}
{/block} {block name="body"}
<div class="layui-body layui-tab-content index-body" id="cont">
	<div class="park-navigation">
		<div class="navigation-icon">
			<i class="fa {$breadCrumb[0]['icon']}"></i>
		</div>
		<div class="navigation-menu">
			<h2>{$breadCrumb[0]['title']}</h2>
			{if isset($breadCrumb[1])}
			<p>{$breadCrumb[0]['remark']}</p>
			{/if}
		</div>
	</div>
	<div class="park-content">
		<div class="content-title">
			<div class="title col-8">
				<h3>{$breadCrumb[1]['title']}</h3>
				<form class="layui-form" action="{:url('basic/danger/search')}"  onsubmit="return false;">
					<button class="search-btn" lay-submit lay-filter="search"><img src="__STATIC__/img/base/topsearch01.png"></button>
					<select name="enterpriseId">
						<option value="">单位</option>
						{volist name="enterpriseList" id="item"}
						<option value="{$key}">{$item}</option>
						{/volist}
					</select>
					<input class="search-input" name="keyword" type="text" placeholder="危化品库" id="keyword"  autocomplete="off">
				</form>	
			</div>
			<div class="tool col-2">
				<button id="add"  data-url="{:url('basic/danger/add')}"><i class="fa fa-plus"></i></button>
				<button id="reload"><i class="fa fa-refresh"></i></button>
			</div>
		</div>
		<div class="layui-content" lay-accordion id="danger" data-url="{:url('basic/danger/index')}">
                    
    	</div>
	</div>
</div>
{/block}
{block name="script"}

<script type="text/javascript" src="__JS__/basic/danger.js"></script>

<script id="tableTemplate" type="text/html">
	
        {{# for(var i = 0;i < d.length; i++){ }}
		<div class="maintab">
        <table class="danger-table">
           	<thead>
			<tr>
                <th>名称</th>
				<th>所在公司</th>
                <th>仓库类型</th>

				<th>图片</th>
				<th>负责人</th>
				<th>状态</th>
				<th>审核</th>
                <th style="text-align:center;">
				
				</th>
            </tr>
			</thead>
			<colgroup>
                 <col width="10%">
                 <col width="20%">
				 <col width="10%">
				 <col width="10%">
 				 <col width="15%">
				 <col width="10%">
				 <col width="10%">
            </colgroup>
			<tbody>
  				<tr>
					{{# if(d[i].latitudeLongitude){ }}
					<th class="collapse"><a href="#" class="name" data-url="{:url('basic/hazard/setBuilding')}?position={{d[i].latitudeLongitude}}&hazardId={{d[i].id}}" style="color:#1e9fff">{{d[i].name}}</a></th>
					{{# }else{ }}
					<th class="collapse">{{d[i].name}} <span style="color: red">(未定位)</span></th>
					{{# } }}
					<th class="collapse">{{d[i].enterprise.fullName}}</th>
                 	<th class="collapse">{{d[i].typeId}}</th>
					<th class="collapse">
						{{# if (d[i].imgPath){ }}
							<img src="__PUBLIC__{{d[i].imgPath}}"></img>
						{{# } }}
					</th>
					<th class="collapse">
						{{# if (d[i].staff){ }}
							<p><span>{{d[i].staff.staffName}}</span></p>
							<p><span>电话:{{d[i].staff.tel}}</span></p>
							<p><span>手机:{{d[i].staff.mobile}}</span></p>
						{{# } }}
					</th>
					<th class="collapse">
						<div>
								{{# if (d[i].isValid == 1){ }}
								<p>有效性: <span class="layui-badge-circle layui-bg-green"><i class="fa fa-check"></i></span></p>
								{{# }else{ }}
								<p>有效性: <span class="layui-badge-circle layui-bg-red"><i class="fa fa-close"></i></span></p>
								{{# } }}
						</div>
					</th>
					<th class="collapse">
						<div>
							{{# if (d[i].checkStatus == 1){ }}
								<p class="badge-audit-state pending-approval"></p>
							{{# } }}
							{{# if (d[i].checkStatus == 2){ }}
								<p class="badge-audit-state under-review"></p>
							{{# } }}
							{{# if (d[i].checkStatus == 3){ }}
								<p class="badge-audit-state check-success"></p>
							{{# } }}
						</div>
					</th>	
					<th>
						{{# if(d[i].checkStatus == 1) { }}
						<a class="layui-btn btn-config add-chemical"  data-url="{:url('basic/danger/addChemical')}?dangerId={{d[i].id}}"><i class="fa fa-plus"></i></a>
						<a class="layui-btn btn-edit edit-danger"  data-url="{:url('basic/danger/edit')}?dangerId={{d[i].id}}"><i class="fa fa-pencil"></i></a>
  						{{# } }}
						<a class="layui-btn btn-del del-danger" data-url="{:url('basic/danger/del')}?dangerId={{d[i].id}}"><i class="fa fa-trash"></i></a>
						{{# if(d[i].checkStatus == 1) { }}
						<a class="layui-btn btn-audit" lay-event="audit" id="audit_{{d[i].id}}" data-url="{:url('basic/danger/audit')}" data-id="{{d[i].id}}"><i class="fa fa-file-text"></i></a>
						{{# } }}
					</th>
            	</tr>
			</tbody>
        </table>
        {{# if(d[i].chemicals != null){ }}
            <div class="maintab">
                <table class="chemical-table detail-table">
                    <colgroup>
						<col width="10%">
                        <col width="20%">
                 		<col width="10%">
				 		<col width="20%">
                    </colgroup>
                    <tbody>
                        {{# for(var j = 0;j < d[i].chemicals.length; j++){ }}
                        <tr>
							<td>
								{{d[i].chemicals[j].chineseName}}
							</td>
                            <td>
                              	{{d[i].chemicals[j].typeId}}
                            </td>

							 <td>
                                 <form class="layui-form layui-clear" action="{:url('basic/danger/editChemical')}" method="post" id="chemical_{{d[i].chemicals[j].id}}">
									<div class="layui-input-block" style="margin-left:0;">
       									<input class="layui-input" name="stock" data-set="stock" type="text" value="{{d[i].chemicals[j].pivot.stock}}" />
										<input type="hidden" name="chemicalId" value="{{d[i].chemicals[j].id}}"/>
										<input type="hidden" name="dangerId" value="{{d[i].id}}"/>
										<input type="hidden" name="id" value="{{d[i].chemicals[j].pivot.id}}"/>
            				 		</div>
								 </form>
                            </td>
                            <td style="text-align:center;">
								<span><a class="layui-btn btn-edit edit-chemical" data-id="{{d[i].chemicals[j].id}}"><i class="fa fa-pencil"></i></a></span>
                                <span>
									<a class="layui-btn btn-del del-chemical" data-url="{:url('basic/danger/delChemical')}" data-danger="{{d[i].id}}" data-chemical="{{d[i].chemicals[j].id}}">
										<i class="fa fa-trash"></i>
									</a>
								</span>
                            </td>
                        </tr>
                         {{# } }}
                    </tbody>
                </table>
            </div>
          {{# } }}
		</div>
      {{# } }}
</script>
{/block}

